@include('widget.admin.adminnav',['url'=>'/index.php/admin/user/list','name'=>$type=='edit'?'编辑活动':'添加活动','title'=>'活动管理'])
<form class="form-horizontal" role="form" id="adminMessage">
    <input type="hidden" id="id" value="{{$id or 'new'}}">
    <div class="form-group">
        @include('widget.upload',['bindBtn'=>'activity-logo','uploadTitle'=>'上传logo','deleteImg'=>'delete-logo',
        'backPath'=>'activity-logo-path','showContent'=>'logoImg','defaultImg'=>isset($logo)?$logo:null,'editPath'=>isset($logo)?$logo:''])
    </div>
    <div class="form-group">
        @include('widget.upload',['bindBtn'=>'activity-cover','uploadTitle'=>'上传封面','deleteImg'=>'delete-cover',
        'backPath'=>'activity-cover-path','showContent'=>'coverImg','defaultImg'=>isset($cover)?$cover:null,'editPath'=>isset($cover)?$cover:''])
    </div>
    <div class="form-group">
        <label for="username" class="col-sm-2 control-label">活动名称</label>
        <input type="hidden" name="id" value="{{$id or 'new'}}">
        <div class="col-sm-6">
            <input type="text" class="form-control" id="name" value="{{$name or ''}}" placeholder="请输入活动名称">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10"  style="margin-top: 10px;">
            <button type="button" class="btn btn-primary" onclick="userHandler()">提交</button>
            <button type="reset" class="btn btn-default">重填</button>
        </div>
    </div>
</form>
<script>
    function userHandler(event) {
        var event = event || window.event;
        event.preventDefault(); // 兼容标准浏览器
        window.event.returnValue = false; // 兼容IE6~8
        var _data = {
            'id':$("#id").val(),
            'logo':$("#activity-logo-path").val(),
            'cover':$("#activity-cover-path").val(),
            'name' :$("#name").val()
        };
        if (_data.logo==''){
            dialog.error('请选择logo');
            return;
        }else if(_data.cover==''){
            dialog.error('请选择封面');
            return;
        }else if(_data.name==''){
            dialog.error('请输入活动名称');
            return;
        }
        var Url="/index.php/admin/activity/save";
        dialog.confirm("确认保存？",function callback(){
            $.ajax({
                type:"post",
                data:_data,
                url:Url,
                dataType:"json",
                success:function(data){
                    if(data.res==1){
                        var _url="/index.php/admin/activity/list";
                        dialog.success("操作成功！",_url);
                    }else{
                        dialog.error(data.msg);
                    }
                }
            });
        });
    }
</script>